package com.bafa.front.postlogon;

import com.bafa.dbcache.LeagueCache;
import com.bafa.exceptions.ErrorException;
import com.bafa.front.presentationbeans.TeamBean;
import com.bafa.front.utils.FrontUtils;
import com.bafa.objects.Match;
import com.bafa.objects.PageBean;
import com.bafa.objects.Team;
import com.bafa.services.RetrieveServices;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class DisplayMatchReportEntryServlet extends PostLogonServlet{
   
    
    public void doPostLogonEvent(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, ErrorException {
            
                    String matchId = request.getParameter("matchId");
                    Match match = RetrieveServices.getMatch(new Integer(matchId).intValue());
                    TeamBean team = FrontUtils.getLoggedOnTeam(request);
                    String oppoName = "";
                    if(match.getTeamA()==team.getId()){
                            oppoName=match.getTeamBName();
                    }else{
                            oppoName=match.getTeamAName();
                    }
                    request.setAttribute("MATCH",match);
                    PageBean pageBeanTemp = (PageBean)LeagueCache.getPages().get("report");
                    pageBean = new PageBean(pageBeanTemp);
                    String pageHeader = pageBean.getPageheader().replaceAll("<1>",oppoName);
                    
                    pageBean.setPageheader(pageHeader);
            
            
    }
}
